<?php

use yii\db\Migration;

/**
 * Handles the creation of table `project`.
 */
class m170913_075729_create_project_table extends Migration
{
    /**
     * @inheritdoc
     * 项目表
     */
    public function up()
    {

        $this->createTable('project', [
            'id' => $this->bigPrimaryKey(),
            'code' => $this->string()->notNull()->comment('项目编号'),
            'title' => $this->string()->notNull()->comment('名称'),//与借款人为同一个值
            'package_id' => $this->bigInteger()->notNull()->comment('所属资产包'),
            'category' => $this->smallInteger()->notNull()->comment('类型'),//1保证类、2抵押类、3混合类
            'access' => $this->string()->notNull()->defaultValue('0')->comment('访问权限'),//0公开、1私密（上传者系统中ID，）、2部分访问
            'access_users' => $this->string()->notNull()->comment('部分访问的人的ID'),
            'status' => $this->smallInteger()->notNull()->comment('项目状态'),//1启动尽调、2已立项、3已评估、4已受让、5待跟进
            'borrower' => $this->string()->notNull()->comment('借款人'),
            'province' => $this->integer()->notNull()->comment('省份'),
            'city' => $this->integer()->notNull()->comment('城市'),
            'industry' => $this->string()->notNull()->comment('行业'),
            'type' => $this->string()->notNull()->comment('类型'),
            'management_status' => $this->smallInteger()->notNull()->comment('经营状态'),//1破产、2存续、3吊销、4注销、5在营、6其它
           // 'currency' => $this->smallInteger()->notNull()->defaultValue('1')->comment('币种'),//1人民币、2美元、3港元
            'principal' => $this->string()->notNull()->comment('本金（元）'),
            'interest' => $this->string()->notNull()->comment('利息（元）'),
            'is_highlights' => $this->smallInteger()->comment('是否为亮点项目'),//1是2否
            'highlights' => $this->text()->notNull()->comment('亮点明细'),
            'is_suit' => $this->smallInteger()->notNull()->defaultValue('0')->comment('诉讼情况'),//0未诉1已诉
            'guarantor' => $this->string()->notNull()->comment('（保证、混合类项目）保证人'),
            'guarantor_status' => $this->smallInteger()->notNull()->comment('保证人经营状况'),//存续、吊销、注销、破产等同上
            'warranty' => $this->text()->notNull()->comment('担保方式'),
            'mortgage_type' => $this->smallInteger()->notNull()->comment('（保证、混合类）抵押物类型'),//1房产、2土地、3设备、4股权、5无形资产、6其它
//            'area' => $this->string()->notNull()->comment('建筑面积（平方米）'),
//            'address' => $this->string()->notNull()->comment('位置'),
//            'quanzheng' => $this->string()->notNull()->comment('他项权证'),
            'created_at' => $this->dateTime()->notNull()->comment('创建时间'),
            'update_at' => $this->timestamp()->notNull()->comment('创建时间'),
            'lock_user' => $this->integer()->comment('上锁用户'),
            'lock_timestamp' => $this->string()->comment('上锁时间'),
        ]);
    }

    /**
     * @inheritdoc
     */
    public function down()
    {
        $this->dropTable('project');
    }
}
